package com.dhcc.core.api.shiro;

import org.apache.shiro.authc.AuthenticationToken;

import com.dhcc.core.modules.system.entity.User;

/**
 * 用于授权的Token对象：
 *
 * 用户身份即用户名； 凭证即客户端传入的消息摘要。
 * 
 * @ClassName: ApiAuthenticationToken
 * @Description: TODO
 * @author: cyf
 * @date: 2018年1月2日 上午10:07:11
 */
public class ApiAuthenticationToken implements AuthenticationToken {
    private static final long serialVersionUID = 1L;
    private String username;// 用户身份即用户名；
    private String auth;// 凭证即客户端传入的消息摘要。
    private User user;// 用户

    public ApiAuthenticationToken() {
    }

    public ApiAuthenticationToken(String username, String auth) {
        super();
        this.auth = auth;
        this.username = username;
    }

    public ApiAuthenticationToken(User user, String auth) {
        super();
        this.auth = auth;
        this.username = user.getLoginName();
        this.user = user;
    }

    @Override
    public Object getPrincipal() {
        return username;
    }

    @Override
    public Object getCredentials() {
        return auth;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getAuth() {
        return auth;
    }

    public void setAuth(String auth) {
        this.auth = auth;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

}